package com.kaijie.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kaijie.entity.RoomSortInfnEntity;
import com.kaijie.service.RoomSortInfnService;
import com.kaijie.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kaijie.entity.RoomInfnEntity;
import com.kaijie.service.RoomInfnService;
import com.kaijie.utils.PageUtils;
import com.kaijie.utils.R;



/**
 * 
 *
 * @author Jy
 * @email 846021119@qq.com
 * @date 2022-02-28 12:02:21
 */
@RestController
@RequestMapping("kaijie/roominfn")
public class RoomInfnController {
    @Autowired
    private RoomInfnService roomInfnService;


    /**
     * 列表
     *  ********
     * **********
     *  ********
     */
    @RequestMapping("/list")
    @RequiresPermissions("kaijie:roominfn:list")
    public R list(@RequestParam Map<String, Object> params){

        return R.ok().put("data", roomInfnService.list());
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("kaijie:roominfn:info")
    public R info(@PathVariable("id") Integer id){
        RoomInfnEntity roomInfn = roomInfnService.getById(id);
        return R.ok().put("roomInfn", roomInfn);
    }





    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("kaijie:roominfn:save")
    public R save(@RequestBody RoomInfnEntity roomInfn){
        roomInfnService.save(roomInfn);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("kaijie:roominfn:update")
    public R update(@RequestBody RoomInfnEntity roomInfn){
        ValidatorUtils.validateEntity(roomInfn);
        roomInfnService.updateById(roomInfn);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("kaijie:roominfn:delete")
    public R delete(@RequestBody Integer[] ids){
        roomInfnService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
